

public class Place {

	int position=0;
	int branche;

	int x=0, y=0;
	int[] neigbors;
	int free=-1; //the player number 0..6 on this place -1 => free 

	int bx,by;
	/***
	 * 
	 * @param position
	 * @param x
	 * @param y
	 * @param branche
	 * @param bx
	 * @param by
	 * <br>bx and by are bande 
	 * <br>On this picture each place contain  bx:by:<br>
	 * <img src="resources/bx_by.jpg" alt="Places bande" />
	 */
	public Place(int position,int x, int y,int branche,int bx,int by) {
		this.position=position;
		this.x=x;
		this.y=y;
		this.branche=branche;
		this.bx=bx;
		this.by=by;

	}
	/***
	 * @return the level of this place 
	 * <img src="resources/level.jpg" alt="Level" />
	 */
	public int GetLevel(){ 
		if(position>107)return 2;
		else if(position>83)return 3;
		else if(position>47) return 4;
		return 5;
	}

	/***
	 * @param position
	 * @return the level of the place at position (param) 
	 * <img src="resources/level.jpg" alt="Level" />
	 */
	public static int getLevel(int position){ 
		if(position>107)return 2;
		else if(position>83)return 3;
		else if(position>47) return 4;
		return 5;
	}

	/***
	 * 
	 *the same of rotate_to_absolute with a message for debugging
	 *@deprecated 
	 */
	public static int rotate_to_absolute(int abssrc,int position,String mess){
		System.out.println("absolute rotation of "+abssrc+" message="+mess);
		return rotate_to_absolute( abssrc, position);
	}


	/***
	 * 
	 * @param relsrc
	 * @param position
	 * @return return relsrc in absolute coordinate for the player position
	 */
	public static int rotate_to_absolute(int relsrc,int position){


		position-=3;
		if (position>0)position-=6;
		//position= -position;
		position=6+position;

		for (int k=0;k<position;k++){ //replace it by rotation function
			relsrc=Place.rotate_one_time(relsrc);	
		}
		return relsrc;
	}
	/***
	 * 
	 *the same of rotate_to_position with a message for debugging
	 *@deprecated 
	 */
	public static int rotate_to_position(int abssrc,int position,String mess){
		System.out.println("relative rotation  of "+abssrc+" message="+mess);
		return rotate_to_position( abssrc, position);
	}

	/***
	 * 
	 * @param abssrc
	 * @param position
	 * @return return abssrc in relative coordinate for the player position
	 */
	public static int rotate_to_position(int abssrc,int position){



		position-=3;
		if (position>0)position-=6;
		position= -position;

		for (int k=0;k<position;k++){ //replace it by rotation function
			abssrc=Place.rotate_one_time(abssrc);	
		}
		return abssrc;
	}

	private static  int rotate_one_time(int i){
		//  reverse clock rotation
		if (i<40)return (i+8);
		if (i<48)return (i-40);


		if (i<78)return (i+6);
		if (i<84)return i-30;


		if (i<104)return (i+4);
		if (i<108)return i-20;


		if (i<118)return (i+2);
		if (i<120)return (i-10);

		return 120;
	}




}
